package com.zw.stock_sell_storage.config;


import com.zw.stock_sell_storage.interceptor.LoginInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * 拦截器配置类，用来注册拦截器
 */
@Configuration
public class MvcInterceptorConfig implements WebMvcConfigurer {
    //注册拦截器的方法
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        //注册拦截器
        //.addPathPatterns() 添加需要拦截的路径 /** 代表拦截所有的请求
        //.excludePathPatterns() 放行的请求路径
        registry.addInterceptor(new LoginInterceptor())
                .addPathPatterns("/**")
                //.excludePathPatterns("file:D:\\javaCode\\project\\stock_sell_storage\\stock_sell_storage\\target\\classes\\static\\images/")
                .excludePathPatterns("/user/login")
                .excludePathPatterns("/face/**")
                .excludePathPatterns("/JWTTest/send")
                ;
    }
}
